﻿using System;
using System.Threading;

namespace Demo
{
    class Program
    {
        static void Main(string[] args)
        {
           

            var a = new A();
            a.Say();


          

            Console.Read();
            Console.WriteLine("Hello World!");
        }
    }

    public class A {

        SimpleHybridLocked _locked = new SimpleHybridLocked();



        public void Say()
        {

            var t1 = new Thread(() => {
                _locked.Enter();
                Say2("t1");
                _locked.Leave();
              
               
            });


            var t2 = new Thread(() => {
                _locked.Enter();
                Say2("t2");
                _locked.Leave();
            });

            Console.WriteLine("t1:"+ t1.ManagedThreadId);
            Console.WriteLine("t2:" + t2.ManagedThreadId);

            t1.Start();
            t2.Start();

           
        }

        public void Say2(string str)
        {
            Console.WriteLine(str+"say2............");
            Thread.Sleep(3000);
        
        }


    }

}
